'use strict';
var React = require('react');

var DescTextarea = React.createClass({
	getInitialState:function(){
		return {
			desc:''
		}
	},
	componentWillReceiveProps:function(nextProps){
		console.log('DescTextarea.componentWillReceiveProps....');
		console.log(nextProps);
		// this.setState({desc:'abc'});
		this.state.desc = !nextProps.curValue ? '' : nextProps.curValue;
	},
	componentDidMount:function(){
		console.log('componentDidMount');
		this.setState({desc:this.props.curValue});
	},
	_handleChange:function(e){
		this.setState({desc: e.target.value});
		if(this.props._answer){
			this.props._answer(e.target.value);
		}
	},
	render :function(){
		console.log('DescTextarea render .........');
		console.log(this.state.desc);
		return (
			<div className='panel-footer'>
				<textarea 
				style={{width:'100%',height:'200px'}} 
				value={this.state.desc} 
				onChange={this._handleChange}></textarea>
			</div>
		);
	}
});

module.exports = DescTextarea;